package org.techmore.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class GalleryImageAdapter extends BaseAdapter {

	private Context m_context;

	private Bitmap[] m_imageBitmaps;

	public GalleryImageAdapter(Context context, Bitmap[] imageBitmaps) {
		m_context = context;
		m_imageBitmaps = imageBitmaps;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return m_imageBitmaps.length;
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		ImageView imageView = new ImageView(m_context);

		imageView.setLayoutParams(new Gallery.LayoutParams(240, 240));// 设置布局、
																		// 图片200×200显示
		imageView.setImageBitmap(m_imageBitmaps[position]);// 给ImageView设置资源
		imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE );//
		imageView.setAdjustViewBounds(false);

		return imageView;
	}

}
